<?php
/*
 * Created on Feb 23, 2010
 *
 * To change the template for this generated file go to
 * Window - Preferences - PHPeclipse - PHP - Code Templates
 */
	include('includes/session.php');
		
	$contentTypeId = $_GET['contenttypeid'] ? $_GET['contenttypeid'] : 0;	
	if ($contentTypeId == INTRO_ID) $title = HD_INTRODUCTION;
	if ($contentTypeId == NEWS_ID) $title = HD_NEW;
	if ($contentTypeId == PROJECT_ID) $title = HD_PROJECT;		
	if ($contentTypeId == SERVICE_ID) $title = HD_SERVICE;		
		
	include('header.inc');
	include('lefter.inc');
	
	$start = $_GET['start'] ? $_GET['start'] : 0;
	if (strlen($start) > 0 and !is_numeric($start)){
		echo "Data Error"; exit;
	}
	$eu = ($start - 0); 
	$limit = $number_record_perpage;                                 
	$this1 = $eu + $limit; 
	$back = $eu - $limit; 
	$next = $eu + $limit;	
	
	$contentTypeId = $_GET['contenttypeid'] ? $_GET['contenttypeid'] : 0;
	$num = $infoModel->countItemContentType($contentTypeId);
	$items = $infoModel->getItemsContentTypeById($contentTypeId, $eu, $limit); 	

	echo '<div id="col3">';
		echo '<div id="col3_content" class="clearfix"><a id="content" name="content"></a>';
	        echo '<div class="subcolumns_oldgecko widget_space">';
			
				// begin content
				echo '<div class="widget_margins">';
					echo '<div class="floatbox">';
						echo '<div id="topExperts">';
							$i = 0;
							while ($row = $infoModel->getArrayNameInfos($items)) {		
								echo '<ul class="li_elements search">';
									// thong tin nha dat
									echo '<li class="li_experts vcard" id="id65633">';
										echo '<h3 class="fn url"><a href="itemdetail.php?itemdetailid='.$row['id'].'&contenttypeid='. $row['rees_contenttype_id'] .'" class="org url person">&nbsp;&nbsp;'.$row['title'];
										if ($i < 3 && ($eu == 0))
											echo '<img src="images/new.gif" border="0"/></a>';
											else echo '</a>';
										echo '</h3>';
										echo '<a href="itemdetail.php?itemdetailid='.$row['id'].'" title="">';
											$fileName = 'img/upload/content/'.$row["image"];
											if ($row["image"] && file_exists($fileName)) {
												echo '<img class="photo" alt="" src="'.$fileName.'" />';
											}else{
												echo '<img class="photo" alt="" src="img/NoPhotoAvailable.jpg" />';
											}
										echo '</a>';
										echo '<p class="li_experts_content">';
											echo '<span class="tags">'.truncate($row['header'], 400).'<br/></span>';															
										echo '</p>';
										echo '<div class="li_experts_tb">';
											echo '<div class="icon-li-publications" title="Publications">Ngày đăng: '.ConvertSQLDate($row['updateDate']).'</div>';															
										echo '</div>';												
									echo '</li>';
								echo '</ul>';
								$i++;
							}
						echo '</div>';
					echo '</div>';
				echo '</div>';
				// end content
				
				// Paginate
				if ($num > $limit) {
					echo '<div id="pager">Trang ';
					if ($back >= 0) {
						echo '<a href="'.$_SERVER['PHP_SELF'].'?&contenttypeid='.$contentTypeId.'&start='.$back.'"><img src="img/icons/arrow_left.gif" width="16" height="16" /></a>';
					}
					$i = 0;
					$l = 1;
					for ($i = 0; $i < $num; $i = $i + $limit) {
						if ($i <> $eu) {
							echo " <a href='".$_SERVER['PHP_SELF']."?&contenttypeid=".$contentTypeId."&start=$i'><font face='Verdana' size='2'>$l</font></a> ";
						}else { 
							echo '<span style="font-size: 18px; color: red;">'.$l.'</span>';			
						}
						$l = $l + 1;
					}
					if($this1 < $num) {
						echo '<a href="'.$_SERVER['PHP_SELF'].'?&contenttypeid='.$contentTypeId.'&start='.$next.'"><img src="img/icons/arrow_right.gif" width="16" height="16" /></a>';
					}
					echo ' Tổng cộng <strong>'.$num.'</strong> thông tin';
					echo '</div>';
				} 
				// End paginate
				
			echo '</div>';
		echo '</div>';
	echo '</div>';
								
	include('footer.inc');
?>
